<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AddEleToBaseSupplier extends Migrator
{
    public function up()
    {

        $this->table('base_supplier')
            ->addColumn('type',"string",['limit' => 30,'default' =>'','comment'=>"供应商分类"])
            ->save();

        \app\model\BaseSupplier::findOrCreate([
            'code' =>'jutuike',
            'serv_type' =>PRODUCT_ELE_SERV,
            'api_config' => '{"apikey":"1659tQgC9rtsgyx8zHpVtqc2kXGO77Rm"}',
            'name' => '聚推客-饿了么渠道',
            'type' =>\app\model\BaseSupplier::TYPE_TAKEOUT,
            'settle_type' => \app\model\BaseSupplier::SETTLE_TYPE_COMMISSION,
        ]);


        \app\model\BaseSupplier::findOrCreate([
            'code' =>\app\model\BaseSupplier::CODE_MEITUAN_WAIMAI,
            'serv_type' =>PRODUCT_MEITUAN_TAKEOUT_SERV,
            'api_config' => '{"apikey":"75a7459b5c99785eb84f639c1c72205c","secret":"310dac2e7710db5a48b60016c1396cbf"}',
            'name' => '美团外卖',
            'type' =>\app\model\BaseSupplier::TYPE_TAKEOUT,
            'settle_type' => \app\model\BaseSupplier::SETTLE_TYPE_COMMISSION,
        ]);

        \app\model\BaseSupplier::findOrCreate([
            'code' =>\app\model\BaseSupplier::CODE_MEITUAN_DAODIAN,
            'serv_type' =>PRODUCT_METUAN_SERV,
            'api_config' => '{"apikey":"b4KcJ6tiDX6wE1t7","utmSource":"84478","promotionId":39297,"act_id":"0AlN4OtEIa"}',
            'name' => '美团到店',
            'settle_type' => \app\model\BaseSupplier::SETTLE_TYPE_COMMISSION,
        ]);





    }

    public function down()
    {

        $this->table('base_supplier')
            ->removeColumn('type')
            ->save();

    }
}
